package com.joyhonest.ruler;

import android.content.res.Resources;

/**
 * Created by snoopy on 2017/9/15.
 */
public class DensityUtil {
    public static int dip2px(float dipValue) {
        final float scale = Resources.getSystem().getDisplayMetrics().density;
        return (int) (dipValue * scale + 0.5f);
    }

    public static int px2dip(float pxValue) {
        final float scale = Resources.getSystem().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }
}
